<?php 
function subwords($words,$num){

	$total_num = str_word_count($words); 

	if($total_num <= $num){  
		return $words;
	}else{
		$pattern = '/([\S]+?[ ]+){'.$num.'}/';
		preg_match($pattern, $words, $out);
		return $out[0].'...'; 
	}
}

?>
<?php $posts = $this->getPosts(); ?>
<div class="title">
	<div class="pagebar">
		<?php $this->getPages(); ?>
	</div>
	<h1><?php echo $this->getCat()->getTitle();?></h1>
</div>
<h6>Please browse our sectors articles using the list provided. You can view the full article by selecting an item from below </h6>
<div class="sectorsList">
	<?php foreach ($posts as $post): ?>
	<div class="sectorsListItems">
		<a class="sphoto" href="<?php echo $post->getAddress(); ?>"><img src="<?php echo Mage::getBaseUrl('media').$post->getNfilethumb();?>"></a>
		<h3><a href="<?php echo $post->getAddress(); ?>"><?php echo $post->getTitle();?></a></h3>

		<p><?php echo $post->getPostContent(); ?></p>
		<div class="clearboth"></div>
	</div>
	<?php endforeach; ?>
</div>
<div class="claerboth"></div>

